#include "AABBCollider.h"
#include "entity.h"
#include "geom.h"
#include "Physics.h"

AABBCollider::AABBCollider(Entity* entity,float width, float height, float depth):
Collider(entity,AABB,width,height,depth)
{
	m_width = width;
	m_height = height;
	m_depth = depth;
}


AABBCollider::~AABBCollider(void)
{
}

bool AABBCollider::collideWith(const Collider* collider)
{
	if(collider->m_type == AABB){
		
	}
	else if(collider->m_type == SPHERE){
		Vector3 pos1 = getEntity()->getPosition();
		Vector3 pos2 = collider->getEntity()->getPosition();

		float sqDist = Physics::sqDistPointToBox(pos2.x,pos2.y,pos2.z,pos1.x,pos1.y,pos1.z,m_width/2,m_height/2,m_depth/2);

		return sqDist <= getEntity()->getCollider()->getRadius() * getEntity()->getCollider()->getRadius();

	}


	return false;
}